package com.thoughtmechanix.licensingservice.controllers;

import com.thoughtmechanix.licensingservice.model.License;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController    //⇽---  @Restcontroller告诉Spring Boot这是一个基于REST的服务，它将自动序列化/反序列化服务请求/响应到JSON
@RequestMapping(value="/v1/organizations/{organizationId}/licenses")   // ⇽---  在这个类中使用/v1/organizations{organizationId}/ licenses的前缀，公开所有HTTP端点
public class LicenseServiceController {
    @RequestMapping(value="/{licenseId}",method = RequestMethod.GET)    // ⇽---  使用值创建一个GET端点v1/organizations/  {organizationId}/licenses{licenseId}
    public License getLicenses(
 @PathVariable("organizationId") String organizationId,
 @PathVariable("licenseId") String licenseId) {   // ⇽---  从URL映射两个参数（organizationId和licenseId）到方法参数
        return new License()
                .withId(licenseId)
                .withProductName("Teleco")
                .withLicenseType("Seat")
                .withOrganizationId("TestOrg");
    }
}